package com.onesports.intelligent.k12.polarlight.mapper.market;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.onesports.intelligent.k12.polarlight.annotation.DataPermission;
import com.onesports.intelligent.k12.polarlight.domain.dto.operation.CommissionDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.operation.EvaluateDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.operation.PageOrderDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.organization.OrgEvaluateDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.organization.OrgPageOrderDTO;
import com.onesports.intelligent.k12.polarlight.domain.dto.report.FinanceQueryDTO;
import com.onesports.intelligent.k12.polarlight.domain.entity.market.Orders;
import com.onesports.intelligent.k12.polarlight.domain.vo.operation.CommissionPageVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.operation.StudentOrderVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.order.*;
import com.onesports.intelligent.k12.polarlight.domain.vo.product.WxOrderVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.report.FinanceVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.student.StudentCourseVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.wx.WXFtbOrderByIdVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.wx.WXOrderByIdVO;
import com.onesports.intelligent.k12.polarlight.domain.vo.wx.WxFtbOrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * 课程订单
 *
 * @author
 * @since 1.0.0 2022-07-08
 */
@Mapper
public interface OrdersMapper extends BaseMapper<Orders> {
    /**
     * 运营端-条件分页查询
     *
     * @param dto
     */
    @DataPermission
    IPage<OrderPageVO> findPage(Page<OrderPageVO> page,
                                @Param("dto") PageOrderDTO dto);

    /**
     * 运营端-条件分页查询total
     *
     * @param dto
     */
    @DataPermission
    OrderPageVO findPageTotal(@Param("dto") PageOrderDTO dto);

    /**
     * 根据id查询订单详情
     *
     * @return
     */
    OrderByIdVO findById(@Param("orderId") String orderId);

    /**
     * 运营端-条件分页查询
     *
     * @param dto
     */
    IPage<OrgOrderPageVO> findOrgPage(Page<OrgOrderPageVO> page,
                                      @Param("dto") OrgPageOrderDTO dto,
                                      @Param("organizationId") String organizationId);

    /**
     * 运营端-条件分页查询
     *
     * @param dto
     */
    OrgOrderPageVO findOrgTotal(Page<OrgOrderPageVO> page,
                                @Param("dto") OrgPageOrderDTO dto,
                                @Param("organizationId") String organizationId);

    /**
     * 学员课程订单列表
     *
     * @param studentId 学员第
     * @return List<StudentCourseVO>
     */
    @DataPermission
    List<StudentCourseVO> courseList(@Param("studentId") String studentId, @Param("campusIds") List<String> campusIds, @Param("classStatus") List<String> classStatus);

    /**
     * 分佣分页
     *
     * @param orderPage
     * @param dto
     * @return
     */
    IPage<CommissionPageVO> findCommissionPage(Page<CommissionPageVO> orderPage, @Param("dto") CommissionDTO dto);

    IPage<OrderEvaluatePageVO> findEvaluatePage(Page<OrderEvaluatePageVO> orderPageVOPage, @Param("dto") EvaluateDTO dto);

    /**
     * 小程序-订单查看
     */
    List<WxOrderVO> wxFindOrder(@Param("uesrId") String uesrId);

    List<WxFtbOrderVO> wxFtbOrder(@Param("uesrId") String uesrId);


    IPage<OrgOrderEvaluatePageVO> findOrdEvaluatePage(Page<OrgOrderEvaluatePageVO> orderPageVOPage,
                                                      @Param("dto") OrgEvaluateDTO dto,
                                                      @Param("organizationId") String organizationId);

    List<StudentOrderVO> wxFindStudentOrder(@Param("studentId") String studentId);
    List<StudentOrderVO> wxFindStudentOrderByOrg(@Param("studentId") String studentId,
                                                 @Param("organizationId") String organizationId);

    /**
     * 根据订单Id获取自动扣款通知所需信息
     *
     * @param orderId 订单Id’
     * @return AutoPayVO
     */
    AutoPayVO getPayVo(@Param("orderId") String orderId);

    @DataPermission
    IPage<FinanceVO> selectFinancePage(Page pager, @Param("params") FinanceQueryDTO dto, @Param("organizationId") String organizationId);

    @DataPermission
    List<FinanceVO> selectFinancePage(@Param("params") FinanceQueryDTO dto, @Param("organizationId") String organizationId);

    @DataPermission
    FinanceVO selectFinanceSumValue(@Param("params") FinanceQueryDTO dto, @Param("organizationId") String organizationId);

    WXOrderByIdVO selectWXorderById(@Param("orderId") String orderId);

    WXFtbOrderByIdVO selectWXFtborderById(@Param("tradeId")String tradeId);

    List<Orders> getAttendanceOrders(@Param("payTime") String payTime);
}
